<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class FunctionConfirmType extends ExpressionType implements IRenderable {
	
	private $args;
	private $message;
	
	/**
	 * Constructeur
	 * @param unknown_type $expression
	 */
	public function FunctionConfirmType(array $args, $expression, $messageConfirm) {
		parent::ExpressionType($expression);
		
		$this->args = $args;
		$this->message = $messageConfirm;
	}
	
	/**
	 * renvoie les arguments de la fonction
	 */
	private function getArgs() {
		$str = "";
		$b = false;
		foreach ($this->args as $a) {
			if ($b) $str.= ",";
			$str.= $a;
			$b = true;
		}
		return $str;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return null;
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return null;
	}
	
	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		//
	}

	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		return "function(".$this->getArgs()."){isc.confirm('".$this->message."',function(".$this->getArgs()."){".$this->expression."});}";
	}
}